﻿using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace MyTask.WebApi.Filters
{
    public class GlobalExceptionFilter:IExceptionFilter
    {
        private ILogger<GlobalExceptionFilter> _logger;
        public GlobalExceptionFilter(ILogger<GlobalExceptionFilter> logger, IHostingEnvironment _env)
        {
            _logger = logger;
        }

        public void OnException(ExceptionContext context)
        {
            string message=  context.Exception.StackTrace;
            _logger.LogError(message);
        }

    }
   
}
